<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css1/aui.css" />
    <link rel="stylesheet" href="../css1/base.css">
    <link rel="stylesheet" type="text/css" href="../css1/style.css"/>
    <link rel="stylesheet" type="text/css" href="../css1/iconfont.css"/>
    <style>
       html,body{background-color: #f2f1f1;  }
    }
    </style>
</head>
<body>
  <section class="myui-bg-live">
  <div class="live-top">
    <div class="live-top-l">
      <img id="pic" src="">
    </div>
    <div class="live-top-r">
      <div class="live-top-r-t">
        <span id="title" class="live-ptname" style="color:#fff600">直播</span>
        <span class="live-pt">直播平台</span>
        <div  class="aui-label-list aui-label aui-label-danger aui-iconfont aui-icon-my">
          当前在线人数:
          <i id="num" ></i>
          <span >人</span>

        </div>
      </div>
      <div class="live-top-r-b">
        直播视频与图片均来源于第三方平台，与本app无关，不要相信直播间任何广告，避免上当受骗。
      </div>
    </div>
  </div>
</section>

<div class="br"> </div>
  <div class="wrap">

    <div class="game-page">

    <div class="zhubo-list-wrap" id="liveList">

      <ul class="clearfix" id="div_list">
      </ul>

    </div>

</body>

<script type="text/x-dot-template" id="template">
{{~ it.zhubo : value : index }}
    <li onclick="openWin('{{= value.address }}','{{= value. title }}','{{= value. img }}')" >

      <div class="video-mask-box">

      <img src="{{= value. img }}" alt="" class="game-pic" style="height:350px">

      </div>
      <div  class="aui-badge">直播中</div>
      <div class="til">{{= value. title }}</div>

    </li>
{{~}}
</script>
<script type="text/javascript" src="../script/api.js" ></script>
<script type="text/javascript" src="../script/doT.js"></script>
<script type="text/javascript">

  apiready = function(){
    var title = $api.byId('title');
    var pic = $api.byId('pic');

    pic.src = api.pageParam.xinimg;
    title.innerHTML = api.pageParam.title;


    api.showProgress({
        title: '加载中...',
        modal: false
    });

    api.ajax({
        url: 'http://maLequ.cn/login1/login/zhibjk.html',
        method: 'get'
    },function(ret, err){
        if (ret) {
          api.hideProgress();
          zhubo(ret.msg[0].zhubo);
        } else {
          api.hideProgress();

        }
    });
    getRandom();
  }



  function getRandom(){
  var i = Math.random()*3000+1200;
  document.getElementById("num").innerText = window.parseInt(i);
  }



  function zhubo(zhubo){
    //alert(pingtai);
    var div_list = $api.byId('div_list');
    var template = $api.byId('template');
    api.ajax({
        url: zhubo+api.pageParam.url,
        data:{
        }
    },function(ret, err){
        if (ret) {
          //alert( JSON.stringify( ret ) );
          var pagefn = doT.template(template.text);
          div_list.innerHTML = pagefn(ret);
          //alert( pagefn(ret));
          api.hideProgress();
        } else {
          api.hideProgress();
            //alert( JSON.stringify( err ) );
        }
    });



    api.setRefreshHeaderInfo({
        visible: true,
        loadingImg: 'widget://image/refresh.png',
        bgColor: '#fff',
        textColor: '#333',
        textDown: '下拉刷新...',
        textUp: '松开刷新...',
        showTime: true
    }, function(ret, err){
      if (err) {
        api.toast({
            msg: '加载数据失败',
            duration: 2000,
            location: 'middle'
        });
        api.refreshHeaderLoadDone();
      }else {
        list();
        getRandom();
        api.toast({
            msg: '刷新成功',
            duration: 1000,
            location: 'middle'
        });
        api.refreshHeaderLoadDone();

      }

    });

  }


  function list(){
    api.showProgress({
        title: '加载中...',
        modal: false
    });
    var div_list = $api.byId('div_list');
    var template = $api.byId('template');
    api.ajax({
        url: zhubo+api.pageParam.url,
        method: 'get'
    },function(ret, err){
    	//console.log( JSON.stringify( ret ));
        if (ret) {
          //alert( JSON.stringify( ret ) );
          var pagefn = doT.template(template.text);
          div_list.innerHTML = pagefn(ret);
          api.hideProgress();
        } else {
          api.hideProgress();
            //alert( JSON.stringify( err ) );
        }
    });
}

  function openWin(url,title,img){
    var time = localStorage.getItem('user_time');
    var user_id = localStorage.getItem('user_id');
    var username = localStorage.getItem('user_name');
    var timestamp = Date.parse(new Date())/1000;
    if(user_id==0){
      api.alert({
          title: '温馨提示',
          msg: '请先登陆后使用',
      });
      api.openWin({
          name: 'login',
          url: './login.html',
          delay: 300
      });
      return;

    }

    if (time>timestamp) {

      setTimeout("playRadio();",1000);
      var delay = 0;
      if(api.systemType != 'ios'){
          delay = 300;
      }
      api.openWin({
          name: 'bzhibo_play',
          pageParam:{url:url,title:title,img:img},
          url: 'bzhibo_play.html',
      });

    }else if (time == -1) {

      setTimeout("playRadio();",2000);
      var delay = 0;
      if(api.systemType != 'ios'){
          delay = 300;
      }
      api.openWin({
          name: 'bzhibo_play',
          pageParam:{url:url,title:title,img:img},
          url: 'bzhibo_play.html',
      });


    }else if (time<timestamp){
      var dialogBox = api.require('dialogBox');
      dialogBox.alert({
          texts: {
              content: '您的VIP会员已过期，或者未登录！',
              leftBtnTitle: '去续费',
              rightBtnTitle: '去登录'
          },
          styles: {
              bg: '#fff',
              w: 300,
              content: {
                  color: '#000',
                  size: 14
              },
              left: {
                  marginB: 7,
                  marginL: 20,
                  w: 130,
                  h: 35,
                  corner: 2,
                  bg: '#ff7600',
                  color: '#fff',
                  size: 14
              },
              right: {
                  marginB: 7,
                  marginL: 10,
                  w: 130,
                  h: 35,
                  corner: 2,
                  bg: '#ff7600',
                  color: '#fff',
                  size: 14
              }
          }
      }, function(ret) {
          if (ret.eventType == 'left') {
            api.openWin({
                name: 'open_vip_win',
                url: './open_vip_win.html',
                delay: 300
            });

              var dialogBox = api.require('dialogBox');
              dialogBox.close({
                  dialogName: 'alert'
              });
          }else if (ret.eventType == 'right') {
            api.openWin({
                name: 'login',
                url: './login.html',
                delay: 300
            });
            var dialogBox = api.require('dialogBox');
            dialogBox.close({
                dialogName: 'alert'
            });
          }
      });
    }

  }

</script>
</html>
